The present invention relates generally to computer software development and, more particularly, to computer software debugging.
Java is an object-oriented programming language developed by Sun Microsystems, Mountain View, California. Java is a portable and architecturally neutral language. Java source code is compiled into a machine-independent format that can be run on any machine with a Java runtime system known as the Java Virtual Machine (JVM). The JVM is defined as an imaginary machine that is implemented by emulating a processor through the use of software on a real machine. Accordingly machines running under diverse operating systems, including UNIX, Windows 95, Windows NT, and MacIntosh having a JVM can execute the same Java program.
Java Server Page (JSP) technology is a scripting language technology for controlling the content or appearance of Web pages through the use of server-side applications, known as xe2x80x9cservlets.xe2x80x9d Servlets are Java applications that run on a Web server to modify Web pages before they are sent to requesting clients. Servlets may be referred to as server-side applets or applications. Similar to the way applets run on a browser and extend a browser""s capabilities, servlets run on a Java-enabled Web server and extend the Web server""s capabilities. Servlets use classes and methods in the JavaSoft Java Servlet Application Programming Interface (API). The JavaSoft Java Servlet Application Programming Interface (API) is described at http://www.ibm.com/java/servexp/sedocd.html, which is incorporated herein by reference in its entirety. As is known to those skilled in this art, servlets may be local or remote. That is, servlets may reside on a Web server receiving a request from a Web client or may be located on a server remotely located from the Web server receiving a Web client request.
In response to a client request for a Web page, a JSP file referred to in the requested Web page typically is transformed into (or may call) one or more servlets that execute. A JSP file typically contains source code in a markup language, such as HyperText Markup Language (HTML) and Extensible Markup Language (XML). This source code typically includes all the information needed to call one or more servlets. A servlet typically generates an HTML response to a requesting client.
As is known to those of skill in the art, xe2x80x9cdebuggingxe2x80x9d is the process of locating and fixing or bypassing bugs (errors) in computer program code. Debugging tools are typically available for various software development environments and can be used to help identify coding errors. Many programming language packages include a debugger tool for checking code for errors as it is being written. A debugger tool typically facilitates stepwise (i.e., line-by-line) execution of program instructions that is frozen at prescribed execution intervals to allow user inspection of various aspects of program execution.
Conventional compilers for compiling JSP files into Java class files create an intermediate Java source file that is not visible to the JSP file creator. However, existing debugger tools for debugging a compiled Java class file typically displays the source code of the intermediate Java source file as the source of the Java class file, not the markup language source code of the JSP file. Unfortunately, because an intermediate Java source file is not created by the JSP file creator, the source code of an intermediate Java source file may be of little use to a developer in debugging the original JSP file. Accordingly, there is a need for a debugger that allows a developer to debug a generated Java class file by stepping through the source code of the original JSP file from which the Java class file was generated.
The present invention is directed to systems, methods and computer program products for debugging markup language source code of JSP files via Java class files generated therefrom. The markup language source code within a JSP file is converted to an intermediate Java source file when a client request is directed to the JSP file. The Java source file contains source code in the Java programming language. According to the present invention, non-executable comments are included within the Java source code of an intermediate Java source file to identify portions of the Java source code that correspond to respective portions of the markup language source code in the JSP file.
According to the present invention, debugging operations can be performed on a JSP file using a Java class file generated therefrom. A Java class file is subjected to introspection to locate a source file specifier that identifies the filename of a Java source file from which the Java class file was compiled. The Java class file is also subjected to introspection to identify one or more source-to-bytecode tables associated with the Java class file. A source-to-bytecode table includes information that associates bytecode therewithin to respective portions of Java source code within a Java source file identified by a source file specifier.
According to the present invention, the identified source-to-bytecode tables are modified to include information provided within the comments of the Java source file source code to link respective portions of the Java source code with respective portions of the markup language source code of the JSP file. This modification provides a link between respective bytecodes within the Java class file and respective portions of the markup language source code of the JSP file.
In addition, the located source file specifier is modified to indicate the JSP file as the source file from which the Java class file is compiled. This may be implemented by changing the file name of the Java source file in the source file specifier to the file name of the JSP file.
After the source-to-bytecode tables have been modified as described above and the source file specifier has been modified to indicate the JSP file as the source file of the Java class file, the Java class file can be executed within a JVM debugger tool to debug the markup language source code of the JSP file. The debugger tool is thereby xe2x80x9cfooledxe2x80x9d into believing that the markup language source code of the JSP file matches the bytecode of the compiled Java class file. A user can thereby step through the markup language source code during debugging operations.